<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>作业3 | Hugo Theme Dream</title>

    



<meta name="author" content="Lindixuan" />
<meta name="description" content="" />



<meta name="generator" content="Hugo 0.63.2" />

<link rel="canonical" href="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A3/" />


<meta property="og:title" content="作业3" />
<meta property="og:description" content="" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A3/" />
<meta property="article:published_time" content="2020-09-20T12:48:58+08:00" />
<meta property="article:modified_time" content="2020-09-20T12:48:58+08:00" />



<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="作业3"/>
<meta name="twitter:description" content=""/>


<link rel="stylesheet" href="/css/semantic.min.css" />
<link rel="stylesheet" href="/css/OverlayScrollbars.min.css" />
<link rel="stylesheet" href="/css/github-markdown.css" />
<link rel="stylesheet" href="/css/site.css" />


<style>
  a {
    color: seagreen !important;
  }
</style>



<style>
  .inverted a {
     color: darkseagreen !important;
  }
</style>


    


  
    <link rel="stylesheet" data-highlight href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/gruvbox-light.min.css" />
  



  </head>

  
  <body style="background: white;">
  
    
<nav class="ui secondary inverted menu dream-menu">

  <div class="item">
    <i class="large link bullseye icon dream-flip-toggle" title="Flip it!"></i>
  </div>
  <div class="item">
    <i class="large link home icon" title="Home" onclick="window.location.href = 'https:\/\/lindixuan.gitee.io'"></i>
  </div>
  <div class="item">
    <i class="large link icon theme-switch" onclick="themeSwitch()"></i>
  </div>
  
  <div class="item">
    <i class="large link search icon" onclick="toggleSearch()"></i>
  </div>
  
</nav>

    <div class="flip-container">
      <div class="flipper">
        <section class="front">
          <div class="dream-max-width">
            
<div class="ui centered relaxed grid dream-grid">
  <div class="sixteen wide mobile sixteen wide tablet twelve wide computer column markdown-body dream-single">

    <section class="ui top attached segment" id="dream-save-post-as-img">
      <header style="margin-top: 0 !important;">
        <h1 class="ui large header">
          作业3
          <div class="sub header">
            @
            
              Lindixuan
            
            · Sunday, Sep 20, 2020
            · 2 minute read
            · Update at Sep 20, 2020
          </div>
        </h1>
      </header>

      
        <img class="ui image" style="margin-top: 2rem;" src="" />
      

      <article style="margin-top: 2rem;"><h1 id="part-1">part 1</h1>
<h2 id="write-out-variables-x-y-and-z-in-binary-code">Write out variables x, y and z in binary code</h2>
<ol>
<li>int8_t x = 67;  <strong>01000011</strong><br>
int8_t y = -7;  <strong>11111001</strong><br>
int8_t z = y - x;  <strong>10110110</strong></li>
<li>int8_t x = 0xd3;<strong>溢出错误</strong></li>
<li>uint8_t = 0xd3;<strong>11010011</strong></li>
<li>int8_t x = 127; <strong>01111111</strong><br>
int8_t y = -7;  <strong>10001001</strong><br>
int8_t z = y – x; <strong>溢出错误</strong></li>
<li>float x = 1.125;<strong>00 0001 00 10010000</strong></li>
<li>float x = 23.0;  <strong>00 0101 00 10111000</strong></li>
<li>float x = 0.45;  <strong>00 0000 00 01110011（精度误差）</strong></li>
</ol>
<p>上述代码中，哪些出现溢出错误，哪些出现精度误差。</p>
<h1 id="part-2">part 2</h1>
<h2 id="使用维基百科解释以下概念">使用维基百科，解释以下概念。</h2>
<p>1)Method of complements</p>
<blockquote>
<p>In mathematics and computing, the method of complements is a technique to encode a symmetric range of positive and negative integers in a way that they can use the same algorithm (hardware) for addition throughout the whole range.</p>
</blockquote>
<p>2)Byte</p>
<blockquote>
<p>The byte is a unit of digital information that most commonly consists of eight bits.</p>
</blockquote>
<p>3)Integer (computer science)</p>
<blockquote>
<p>In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values.</p>
</blockquote>
<p>4)Floating point</p>
<blockquote>
<p>In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision.</p>
</blockquote>
<hr>
<h2 id="仔细阅读-method-of-complements的内容">仔细阅读” Method of complements”的内容</h2>
<p>1)请证明：二进制的负数（two‘s complement of X）等于 X 的 ones’complement ＋ 1（即，X每位求反加1）</p>
<blockquote>
<p>假设a为一个8位二进制正数。<br>
a的负数要满足： a+(-a)=0000 0000<br>
对a每位求反得到b，则a+b=1111 1111<br>
则 a+(b+1)=1 0000 0000 舍去最高位后得到 0000 0000<br>
则(b+1)为a的负数，即a的负数为每位求反加1</p>
</blockquote>
<p>2)Int8_t x = - 017; 请用8进制描述变量 x。在c中017即(017)8</p>
<blockquote>
<p>(-017)十进制下等于 -15<br>
原码：1000 0000 0000 0000 0000 0000 0000 1111<br>
补码：1111 1111 1111 1111 1111 1111 1111 0001<br>
八进制：37777777761</p>
</blockquote>
<hr>
<h2 id="阅读维基百科-twos-complement的内容特别是sign-extension小节内容">阅读维基百科” Two‘s complement”的内容，特别是Sign extension小节内容。</h2>
<p>1)C程序：int8_t x = -0x1f; int y = x; 请用16进制描述变量 x 和 y，并说明 int y = x 的计算过程。</p>
<blockquote>
<p>-0x1f十进制下等于 -31<br>
原码：1000 0000 0000 0000 0000 0000 0000 1111<br>
补码：1111 1111 1111 1111 1111 1111 1111 0001<br>
x= 0xfffffff1<br>
y= 0xfff1<br>
int y=x 舍弃16个1</p>
</blockquote>
<p>2)请用数学证明，为什么可以这么计算。</p>
<blockquote>
<p>when a two&rsquo;s-complement number is shifted to the right, the most-significant bit, which contains magnitude and the sign information, must be maintained.
对y求补：1000 0000 0000 1111=-31<br>
舍弃与数符值相同的位可减小位数而不改变数值</p>
</blockquote>
<hr>
<h2 id="3阅读维基百科-floating-point的内容">3阅读维基百科” Floating point”的内容，</h2>
<ol>
<li>NaN 是什么？</li>
</ol>
<blockquote>
<p>In computing, NaN, standing for Not a Number, is a member of a numeric data type that can be interpreted as a value that is undefined or unrepresentable, especially in floating-point arithmetic. Systematic use of NaNs was introduced by the IEEE 754 floating-point standard in 1985, along with the representation of other non-finite quantities such as infinities.</p>
</blockquote></article>
    </section>

    <footer class="ui attached segment dream-tags">
      
          <a class="ui label">No Tags</a>
      
      <div
        class="ui label"
        style="float: right; cursor: pointer;"
        onclick="savePostAsImg()">
        <i class="save icon"></i>Save as image
      </div>
    </footer>

    

    
    
    

  </div>
  <div class="sixteen wide mobile sixteen wide tablet four wide computer column">
    <article class="dream-header">
  <section class="ui top attached center aligned segment">
    <div class="ui small circular image">
      
        <img src="/img/sleep.jpg">
      
    </div>

    
    <h1 class="ui medium header">Lindixuan&#39;s blog<div class="sub header" style="margin-top: 0.5rem;">好耶！</div>
    </h1>
    

    <div class="ui horizontal list">
      
      <a class="item" href="/tags">
        <i class="tags icon" title="All Tags"></i>
      </a>
      <a class="item" href="/categories">
        <i class="th list icon" title="All Categories"></i>
      </a>
    </div>
  </section>

  

  

  <section class="ui attached segment header-socials">
    <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class=" mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

  </section>

  <section class="ui bottom attached center aligned segment">
    
      <p>© 2020 - 2021 Hugo Theme Dream</p>
    

    <p>Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a> with theme <a href="https://github.com/g1eny0ung/hugo-theme-dream" target="_blank">Dream</a>.</p>

    
  </section>
</article>

  </div>
</div>

          </div>
        </section>
        <section class="back">
          <div class="dream-max-width">
            <div class="ui centered relaxed grid dream-grid dream-back">
  
  
  

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    <article>
      <div class="ui top attached segment">
        <h3 class="ui header">Social Links</h3>
      </div>
      <div class="ui bottom attached segment">
        <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class="large mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

      </div>
    </article>
  </section>

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    
  </section>

  
    
  
</div>

          </div>
        </section>
      </div>
    </div>

    <script>
  window.darkNav =  true 
</script>
<script src="/js/jquery.min.js"></script>
<script src="/js/semantic.min.js"></script>
<script src="/js/jquery.overlayScrollbars.min.js"></script>
<script src="/js/header.js"></script>
<script src="/js/main.js"></script>
<script src="/js/theme.js"></script>

    
<script src="/js/html2canvas.min.js"></script>
<script src="/js/post.js"></script>


  <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>

  
    
      <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/languages/ocaml.min.js"></script>
     
  

  <script>
  hljs.initHighlightingOnLoad()
  setHighlightTheme()

  function setHighlightTheme() {
    var isDark = localStore.getItem('hugo-theme-dream-is-dark')
    var lightTheme = "gruvbox-light"
    var darkTheme = "gruvbox-dark"
    var theme = isDark ? darkTheme : lightTheme

    $('link[data-highlight]').attr('href', 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/' + theme + '.min.css')
    $('pre').css('background', isDark ? '#333' : '')
  }
</script>





    
      <div class="ui inverted segment" id="dream-search">
  <div class="ui search">
    <div class="ui transparent input">
      <input class="prompt" type="text" placeholder="Search" />
    </div>
    <div class="results"></div>
  </div>
</div>
<script>
  $(document).ready(function () {
    $.getJSON('https:\/\/lindixuan.gitee.io/index.json', function (data) {
      $('.ui.search').search({
        source: data,
        searchFields: ['title'],
        showNoResults: true,
      })
    })
  })
</script>
<script src="/js/search.js"></script>

    

    
  </body>
</html>
